use std::rc::Rc;

pub use self::common_vmodel::CommonVModel;

use super::{ModelCreateCtx, VModel};

pub mod branch;
pub mod common_vmodel;
pub mod elimate_child_data;
pub mod repeat;
pub mod signal;
pub mod tuple;

macro_rules! impl_vmodel_for_refs {
    ($($T:ty),*) => {
        $(
            impl<T, Cd> VModel<Cd> for $T
            where
                T: VModel<Cd> + ?Sized,
            {
                type Storage = T::Storage;

                fn create(&self, ctx: &ModelCreateCtx) -> Self::Storage {
                    (**self).create(ctx)
                }

                fn update(&self, storage: &mut Self::Storage, ctx: &ModelCreateCtx) {
                    (**self).update(storage, ctx);
                }
            }
        )*
    };
}

impl_vmodel_for_refs!(Box<T>, Rc<T>, &T);
